<?php
class Login_model extends MY_Model {
  	function Login_model(){
        parent::MY_Model();
        $this->load->database();
        $this->table_name = "login";
    }
    
    function select($user){
    	return $this->db->get_where($this->table_name, array('usrname' => $user));
    }
    
    /**
     * 
     * @param $user
     * @param $password
     * @return boolean
     */
    function authenticate($user, $password){
    	$data = $this->select($user);
    	if ($data->num_rows() <= 0) return false;
    	
    	$row = $data->row();
    	if ($row->passwd != $password) return false;
    	
    	return true;
    }
}